package puzzle.hashikake.data;

import java.util.ArrayList;
import java.util.List;

import puzzle.common.point.Pnt;

public class BoardDef {
	private int m_width;
	private int m_height;
	private ShimaDef[] m_shimaArray;
	private List<ShimaDef> m_shimaList;
	private List<HashiDef> m_hashiList;
	
	public BoardDef(int width, int height) {
		m_width = width;
		m_height = height;
		m_shimaArray = new ShimaDef[width * height];
		m_shimaList = new ArrayList<ShimaDef>();
		m_hashiList = new ArrayList<HashiDef>();
	}
	
	public int getWidth() {
		return m_width;
	}

	public int getHeight() {
		return m_height;
	}

	public ShimaDef addShima(int x, int y, int targetNumber) {
		int i = m_shimaList.size();
		ShimaDef shima = new ShimaDef(i, targetNumber, new Pnt(x, y));
		m_shimaArray[x + y * m_width] = shima;
		m_shimaList.add(shima);
		return shima;
	}
	
	public ShimaDef getShima(int x, int y) {
		return m_shimaArray[x + y * m_width];
	}
	
	public ShimaDef getShima(int index) {
		return m_shimaList.get(index);
	}
	
	public HashiDef addHashi(ShimaDef shima1, ShimaDef shima2) {
		int i = m_hashiList.size();
		HashiDef hashi = new HashiDef(i, shima1, shima2);
		m_hashiList.add(hashi);
		return hashi;
	}

	public ShimaDef getShima(Pnt p) {
		return getShima(p.x, p.y);
	}

	public HashiDef getHashi(int index) {
		return m_hashiList.get(index);
	}
	
	public List<HashiDef> getHashiList() {
		return m_hashiList;
	}

	public List<ShimaDef> getShimaList() {
		return m_shimaList;
	}
}
